<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>招工详情</title>
    <link rel="stylesheet" type="text/css" href="../../../../css/aui/aui.css" />
    <style>
        #particulars .aui-list {
            background-image: none;
        }

        #particulars .aui-list .aui-list-item {
            padding-left: 0;
            margin: .5rem .75rem 0;
        }

        #particulars .aui-list .aui-list-item:last-child {
            margin: 0;
            border-top: .5rem solid #f6f6f6;
            border-bottom: .5rem solid #f6f6f6;
            padding: .5rem .75rem 0;
            background-image: none;
        }

        #particulars .aui-list .aui-list-item-inner {
            align-items: flex-end;
            -webkit-align-items: flex-end;
            padding-right: 0.3rem;
        }

        #particulars .aui-list .aui-list-item-right {
            color: #0689FB;
            max-width: 100%;
            font-size: 0.75rem;
        }

        #particulars .aui-list.aui-list-in .aui-list-item {
            background-position: 0 bottom;
        }

        #particulars .no-rim {
            background-image: none;
        }

        #details {
            margin: 0 .75rem;
        }

        #details .aui-col-xs-4{
            height: 33.33333333vw;
            overflow: hidden;
        }

        #details .aui-col-xs-4 img{
            width:100%;
            height:100%;
        }

        #details .details_list_item {
            margin-top: 1rem;
        }

        #details .column_h {
            border-left: 0.2rem solid #0689FB;
            padding-left: 0.4rem;
            font-size: .9rem;
        }

        #details .content {
            color: #2C2C2C;
            margin-top: .5rem;
            margin-bottom: .2rem;
            padding-left: calc(0.4rem + 0.2rem);
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="aui-content" id="particulars">
            <ul class="aui-list aui-list-in">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">项目名称</div>
                        <div class="aui-list-item-right">{{data.title}}</div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">用工地点</div>
                        <div class="aui-list-item-right">{{data.region}}</div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">详细地址</div>
                        <div class="aui-list-item-right">{{data.address}}</div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">用工时间</div>
                        <div class="aui-list-item-right">{{data.work_date}}</div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">金额预算</div>
                        <div class="aui-list-item-right">
                            <span v-if="data.reward == 0">面议</span>
                            <span v-else>{{data.reward}}</span>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item no-rim">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">项目性质</div>
                        <div class="aui-list-item-right">
                            <span v-if="data.work_nature==1">承包制</span>
                            <span v-else-if="data.work_nature == 2">聘用制</span>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">联系人</div>
                        <div class="aui-list-item-right">{{data.contact}}</div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="aui-content" id="details">
            <div class="details_list_item">
                <div class="column_h">项目介绍</div>
                <p class="content">{{data.work_summary}}</p>
                <div class="aui-row-padded">
                    <div class="aui-col-xs-4" v-for="imgs in data.work_image_array"><img :src="imgs" alt=""></div>
                    <div style="clear:both;"></div>
                </div>
            </div>
            <div class="details_list_item">
                <div class="column_h">其他要求</div>
                <p class="content">{{data.other_notes}}</p>
            </div>
        </div>
    </div>
</body>
<script src="../../../../script/api.js" charset="utf-8"></script>
<script src="../../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();
    }

    var vm = new Vue({
        el: "#app",
        data: {
            userInfo: {},
            data: {},
            is_apply_post: 0
        },
        methods: {
            init() {
                this.userInfo = get_local('userInfo');
                this.getDetail();
            },
            getDetail() {
                var self = this;
                _ajax(Config.api.SpecialtyGetDetail, {
                    work_id: api.pageParam.id,
                    user_id: self.userInfo.user_id
                }, function(res) {
                    if (res.code === 200) {
                        self.data = res.data;
                        self.updateCollectStatus(self.data.is_collect);
                    }
                });
            },
            collect() {
                var self = this;
                _ajax(Config.api.SpecialtyCollect, {
                    data_id: self.data.work_id,
                    user_id: self.userInfo.user_id
                }, function(res) {
                    if (res.code === 200) {
                        $toast('收藏成功');
                        self.updateCollectStatus(1);
                    }
                })
            },
            updateCollectStatus(status) {
              console.log(api.pageParam.name);
                api.execScript({
                    script: 'isCollect(' + status + ')'
                });
            }
        }
    });

    function collect() {
        vm.collect();
    }

    function acceptance() {
        if (vm.userInfo.user_id == vm.data.user_id) {
            $toast('不可以自己应聘自己的工作哦!');
            return false;
        }
        if (vm.userInfo.user_status != 2) {
            $toast('请先完善基本资料');
            return false;
        }

        if (vm.userInfo.user_type != 2) {
            $toast('您还不是认证工人, 请先去认证');
            return false;
        }

        // if (vm.data.is_apply == 1) {
        //     $toast('已应聘成功');
        //     return false;
        // }

        // if (vm.is_apply_post == 1) {
        //     $toast('您已经发送应聘申请, 无需重复申请');
        //     return false;
        // }

        // if (vm.is_apply_post == 0 && vm.data.is_apply == 0) {
            _ajax(Config.api.SpecialtyApply, {
                work_id: api.pageParam.id,
                user_id: vm.userInfo.user_id,
                user_type: vm.userInfo.user_status,
                work_user_id: vm.data.user_id
            }, function(res) {
                if (res.code === 200) {
                    $toast('应聘成功');
                    vm.is_apply_post = 1;
                } else {
                    $toast(res.msgs);
                }
            })
        // }
    }
</script>

</html>
